package cn.ismartv.log.interceptor.sample;

import android.test.AndroidTestCase;
import android.util.Log;

import java.io.IOException;

import cn.ismartv.log.interceptor.HttpLoggingInterceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by huaijie on 1/7/16.
 */
public class OkHttpClientTest extends AndroidTestCase {

    private static final String TAG = "OkHttpClientTest ";

//    public void testConnectTimeOut() {
//        OkHttpClient client = new OkHttpClient();
//        int timeout = client.connectTimeoutMillis();
//        Log.i(TAG, "time out is : " + timeout);
//    }

    public void testUrl() {

        final Request request = new Request.Builder().url("http://wx.api.tvxio.com/shipinkefu/getCdninfo?actiontype=getContact&ModeName=Nexus%205&sn=sn%20is%20null").build();
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
        Response resp = null;
        try {
            resp = client.newCall(request).execute();
            String result = resp.body().string();
            Log.i(TAG, result);
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
